package com.xiongwei.manageback.controller;

import cn.hutool.core.bean.BeanUtil;
import com.xiongwei.manageback.DTO.BlogDTO;
import com.xiongwei.manageback.domain.SysBlog;
import com.xiongwei.manageback.service.SysBlogService;
import com.xiongwei.manageback.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    private SysBlogService blogService;

    /**
     * 用户博客列表
     * @return
     */
    @GetMapping("/list/{userId}")
    public AjaxResult blogList(@PathVariable Integer userId){
        return AjaxResult.success(blogService.getByUserId(userId));
    }

    /**
     * 根据id获取博客详情
     */
    @GetMapping("/{id}")
    public AjaxResult blogDetails(@PathVariable Integer id){
        SysBlog blog = blogService.getById(id);
        return AjaxResult.success(blog);
    }

}
